<?php
     defined('_JEXEC') or die;
 ?>
    <div class="swap_slideshow">
      <div class="wrap">
        <div id="slide-holder">
        <?php 
		$db = JFactory::getDbo();
                $query = "select * from #__djimageslider where published =1 and catid = 83";
                $db->setQuery($query);
                $db->query();
                $result = $db->loadObjectList();
                ?>
                
          <div id="slide-runner"> 
              <?php
              foreach($result as $obj){		?>
              <a href="http:" target="_blank"><img id="slide-img-<?php echo $obj->id;?>" src="<?php echo $this->baseurl ?>/<?php echo $obj->image;?>" class="slide" alt="<?php echo $obj->title;?>" ></a>
                <?php }?>
           
        
            <div id="slide-controls" style="display: block;">
              <p id="slide-desc" class="text">Công Trình Cầu</p>
              <p id="slide-nav"></p>
            </div>
          </div>
          <script type="text/javascript">
           if (!window.slider)
          var slider = {};
          slider.data = [
               <?php
              foreach($result as $index=>$obj){
                     $lastitem = (count($subcatnews)==($index+1))?1:'';  
                     if($lastitem)
                         $comma = '';
                     else
                         $comma=',';
                     echo '{"id": "slide-img-'.$obj->id.'", "client": "", "desc": "'.$obj->title.'"}'.$comma.'';
              ?>
              
              <?php }?>          
      ];
          </script> 
        </div>
      </div>
    </div>
    <ul class="products_index">
        <?php 
        $db = JFactory::getDbo();
        $db->setQuery("SELECT * FROM #__content where featured = 1 and state = 1");
        $db->query();
        $result = $db->loadObjectList();
        foreach($result as $index=>$obj){
             $lastitem = (count($result)==($index+1))?1:'';  
            	$images = json_decode($obj->images);
        ?>
        <li <?php if($lastitem) echo 'class="last"'; else echo '';?> > <a href="<?php echo JRoute::_('index.php?option=com_content&view=article&id='.$obj->id.'&Itemid=507') ?>" class="title_product"><?php echo $obj->title; ?></a> 
          <a href="<?php echo JRoute::_(ContentHelperRoute::getArticleRoute($obj->id,$obj->catid)) ?>">
          <?php  if (isset($images->image_intro) and !empty($images->image_intro)) : ?>
				<?php $imgfloat =  $images->float_intro; ?>
				
					<img
					<?php if ($images->image_intro_caption):
					echo 'class="caption"'.' title="' .htmlspecialchars($images->image_intro_caption) .'"';
		endif; ?>
						src="<?php echo htmlspecialchars($images->image_intro); ?>"
						alt="<?php echo htmlspecialchars($images->image_intro_alt); ?>"
						width="235" height="95" />
				
				<?php endif; ?>
          
        </a>
        <div class="detail_product_index"><?php echo trim_text($obj->introtext,40);;?></div>
        <a href="<?php echo JRoute::_(ContentHelperRoute::getArticleRoute($obj->id,$obj->catid)) ?>" class="xemchitiet_product_index"><?php echo JText::_('VIEWDETAILS');?></a> </li>
        <?php }?>
    
    </ul>
<!--    <div class="news_index">
      <div class="title_news_index">Danh mục sản phẩm</div>
      <?php 
      $db = JFactory::getDbo();
      $db->setQuery("SELECT * from #__categories where parent_id = 78 and published = 1 limit 0,10");
      $db->query();
      $result = $db->loadObjectList();
      foreach($result as $obj){
      ?>
      <a href="#" class="news_index"><?php echo $obj->title;?></a> 
      <?php }?>     
      
    </div>-->